//
//  HouseDetailBottomView.m
//  YJRenter
//
//  Created by 文彬 on 2018/7/2.
//  Copyright © 2018年 文彬. All rights reserved.
//

#import "HouseDetailBottomView.h"
#import "UILabel+ChangeLineSpaceAndWordSpace.h"

@implementation HouseDetailBottomView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (id)initWithFrame:(CGRect)frame{
    self = [super initWithFrame:frame];
    if (self) {
        
        [self initControl];
    }
    return self;
}

- (void)initControl{
    
    self.backgroundColor = [UIColor whiteColor];
    
    UIView *lineView= [[UIView alloc]init];
    lineView.backgroundColor = kLineColor;
    [self addSubview:lineView];
    [lineView makeConstraints:^(MASConstraintMaker *make) {
        make.left.top.right.equalTo(@0);
        make.height.equalTo(@0.5);
    }];
    
    UIButton *confimBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    confimBtn.backgroundColor = kMainOriginColor;
    [confimBtn setTitle:@"立即预定" forState:UIControlStateNormal];
    confimBtn.titleLabel.font = [UIFont systemFontOfSize:16];
    [confimBtn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    [self addSubview:confimBtn];
    [confimBtn makeConstraints:^(MASConstraintMaker *make) {
        make.right.top.bottom.equalTo(@0);
        make.width.equalTo(@100);
    }];
    [confimBtn buttonClick:^{
       
        if ([self.delegate respondsToSelector:@selector(HouseDetailBottomViewClickHandle:)]) {
            
            [self.delegate HouseDetailBottomViewClickHandle:kHouseDetailBottomViewClickTypeMakeOrder];
        }
    }];
    
    for (int i=0; i<2; i++) {
        
        UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
        [button setTitle:i==0?@"电话":@"消息" forState:UIControlStateNormal];
        button.titleLabel.font = [UIFont systemFontOfSize:14];
        [button setTitleColor:kTitleColor forState:UIControlStateNormal];
        button.titleEdgeInsets = UIEdgeInsetsMake(30, 0, 0, 0);
        [self addSubview:button];
        [button makeConstraints:^(MASConstraintMaker *make) {
            make.top.bottom.equalTo(@0);
            make.width.equalTo(@50);
            make.right.equalTo(@(i==0?-120:-190));
        }];
        
        UIImageView *imgView = [[UIImageView alloc]init];
        imgView.image = [UIImage imageNamed:@"phone"];
        [button addSubview:imgView];
        [imgView makeConstraints:^(MASConstraintMaker *make) {
            make.width.height.equalTo(@25);
            make.centerX.equalTo(button.centerX);
            make.top.equalTo(@5);
        }];
    }
    
    UILabel *messLabel = [[UILabel alloc]init];
    messLabel.textColor = kSecTitleColor;
    messLabel.font = [UIFont systemFontOfSize:16];
    messLabel.numberOfLines = 0;
    messLabel.textAlignment = NSTextAlignmentCenter;
    messLabel.text = @"当前价格\n￥500";
    [self addSubview:messLabel];
    [messLabel makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(@10);
        make.width.equalTo(@100);
        make.height.equalTo(@50);
        make.centerY.equalTo(self.centerY);
    }];
    [UILabel changeLineSpaceForLabel:messLabel WithSpace:4];
    
    
}

@end
